package com.jumper.cwolf.leetcode;

import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

/**
 * 描述：
 *
 * @author cwolf
 * @version 1.0
 * @date 2021/4/2 11:18
 */
public class Code179 {

    public String largestNumber(int[] nums) {

        Integer[] integers = new Integer[nums.length];
          for(int i=0;i<nums.length;i++){
              integers[i] = new Integer(nums[i]);
          }
        Arrays.sort(integers,(o1,o2)->{
            String s1 = o1.toString();
            String s2 = o2.toString();
            return -(s1+s2).compareTo(s2+s1);
            }
        );
        StringBuilder builder = new StringBuilder();
        for (int i : integers) {
            builder.append(i);
        }
        String s = builder.toString();
        if(s.charAt(0)=='0'){
            return "0";
        }
        return s;
    };

    public static void main(String[] args) {

        int[] arr = new int[]{
                0,3
        };
        String trap = new Code179().largestNumber(arr);
        System.out.println(trap);
    }

}
